/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package main.java.cn.webrx;

import java.io.File;

/**
 * <p>Project: jse2204 - File3
 * <p>Powered by webrx On 2022-09-21 16:59:54
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class File3 {
    public static void main(String[] args) {
        File file = new File("c.txt");
        //文件信息
        System.out.println(file.isFile());
        System.out.println(file.exists());
        System.out.println(file.length());
        System.out.printf("%tF %<tT%n",file.lastModified());
        System.out.println(file.getName());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());
        //文件目录
        String t = file.getAbsolutePath();
        System.out.println(t.substring(0,t.lastIndexOf("\\")));

        //文件基本名
        System.out.println(t.substring(t.lastIndexOf("\\")+1,t.lastIndexOf(".")));

        //文件扩展名
        System.out.println(t.substring(t.lastIndexOf(".")));


        //文件改名 abc.jpg   202209211709241.jpg  移动文件 剪切粘贴
        //file.renameTo(new File("uuuuu.txt"));

        //File ff = new File("uuuuu.txt");
        //ff.renameTo(new File("d:/0824/xyz.txt"));


        //文件删除
        File f3 = new File("d:/0824","xyz.txt");
        if(f3.isFile() && f3.exists()){
            f3.delete();
        }
    }
}
